package com.zlcx.tz.live.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zlcx.tz.live.domain.TimeLearnRoomDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @author anjl
 * 计时学习自习室
 */

@ApiModel(value = "计时自习室信息")
@Data
@Builder
public class TimeLearnRoomVO implements Serializable {

    private static final long serialVersionUID = -2027813761467021724L;
    @ApiModelProperty(value = "id")
    private Long id;

    @ApiModelProperty(value = "所属分类")
    private Integer type;

    @ApiModelProperty(value = "房间名称")
    private String roomName;

    @ApiModelProperty(value = "房间最大人数")
    private Integer roomJoinerMax;

    @ApiModelProperty(value = "已占用的座位数量")
    private Integer usedSeatsNum;

    @ApiModelProperty(value = "座位总数量")
    private Integer totalSeatsNum;

    @ApiModelProperty(value = "计时自习室座位详情信息")
    private List<TimeLearnRoomSeatsVO> seats;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    public static TimeLearnRoomVO from(TimeLearnRoomDO room) {
        return Objects.isNull(room) ? null :
                TimeLearnRoomVO
                        .builder()
                        .id(room.getId())
                        .createTime(room.getCreateTime())
                        .roomJoinerMax(room.getRoomJoinerMax())
                        .roomName(room.getRoomName())
                        .totalSeatsNum(room.getTotalSeatsNum())
                        .usedSeatsNum(room.getUsedSeatsNum())
                        .type(room.getType())
                        .build();

    }

}